<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Dobule Click</title>
    <style>
      html,
      body {
        margin: 0;
        padding: 0;
        width: 100vw;
        height: 100vh;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        align-items: center;
      }
      .button {
        cursor: pointer;
        width: 150px;
        height: 60px;
        background-color: #cfe;
        font-size: 18px;
        border: none;
      }
      .text {
        transition: all 0.4s;
      }
    </style>
  </head>
  <body>
    <div>Double Click：+<span class="text">1</span></div>
    <button class="button">Dobule Click</button>
    <script>
      const color = 'abcdef0123456789'
      const querySelector = element => document.querySelector(element)
      const random = color => color[Math.floor(Math.random() * color.length)]

      const randomColor = () => {
        let value = ''
        for (let i = 0; i < 6; i++) {
          value += random(color)
        }
        return `#${value}`
      }
      const btn = querySelector('.button')
      const body = querySelector('body')
      const text = querySelector('.text')
      // debugger
      console.log(text)
      btn.addEventListener('dblclick', () => {
        body.style.backgroundColor = randomColor()
        document.title = randomColor()

        text.innerHTML = +text.innerText + 1
      })
    </script>
  </body>
</html>
